CXXFLAGS = -g -Wall -rdynamic -march=native -std=c++11 -I../include -L../lib 
CXXFLAGS += -O2

HEADERS=$(wildcard *.h)
TESTS= counter_test \
	   observer_test \
	   observersafe_test \
	   factory_test \
	   signalslot_test \
	   self_deadlock \
	   mutual_deadlock

all: $(TESTS)

$(TESTS): $(HEADERS)

$(TESTS):
	mkdir bin -p
	g++ $(CXXFLAGS) -o bin/$@ $(filter %.cc,$^) $(LDFLAGS) -lmuduo_base_cpp11 -lpthread

counter_test: Counter.cc
observer_test: Observer.cc
observersafe_test: Observer_safe.cc
factory_test: Factory.cc

signalslot_test: SignalSlot_test.cc
signalslot_test: CXXFLAGS += -Wextra -DBOOST_TEST_DYN_LINK
signalslot_test: LDFLAGS += -lboost_unit_test_framework

self_deadlock: SelfDeadLock.cc
mutual_deadlock: MutualDeadLock.cc

clean:
	cd bin
	rm -f $(TESTS)
	rm -rf bin
	cd ..
